package com.sixth.volunteerservicesystem.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.util.ResourceUtils;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.io.FileNotFoundException;


@Configuration
public class MyPiconfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry)  {

        String path= null;
        try {
            path = ResourceUtils.getURL("src/main/resources").getPath()+"static/upload/";
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        registry.addResourceHandler("/upload/**").addResourceLocations("file:"+path);
    }
}